﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace USMCdotNET
{
    public sealed class PathCollection
    {
        bool atprocess = false;
        bool accomplished = false;
        List<BaseLine> lineCollection;
        int[] shift;
        public PathCollection()
        {
            lineCollection = new List<BaseLine>();
            shift = new int[2];
        }
        public bool AtProcess { get { return atprocess; } }
        public bool Accomplished { get { return accomplished; } }

        public List<BaseLine> LineCollection
        {
            get { return lineCollection; }
        }

        public void Move()
        {
            atprocess = true;
            try
            {
                foreach (BaseLine o in lineCollection)
                {
                    o.Move();
                }
            }
            catch (DeviceMovementException e)
            {
                throw e;
            }
            atprocess = false;
            accomplished = true;
        }

        public void ShiftCount()
        {
            foreach (BaseLine o in lineCollection)
            {
                shift[0] += o.Destination.X;
                shift[1] += o.Destination.Y;
            }
        }
        public void Save(BinaryWriter b)
        {
            b.Write("path_collect");

            foreach (BaseLine o in lineCollection)
            {
                o.Save(b);
            }
            b.Write("end_path_collect");
        }
       /* public void Load(BinaryReader a)
        {
            if (a.ReadString() == "path_collect")
            {

            }
        }*/
        public int[] Shift
        {
            get { return shift; }
        }
    }
}
